package cn.wgx.module.ent.mapper;


import cn.wgx.common.base.IBaseMapper;
import cn.wgx.common.entity.ent.Enterprise;
import cn.wgx.common.entity.sys.SysUser;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.apache.ibatis.annotations.Select;

public interface EnterpriseMapper extends IBaseMapper<Enterprise> {

    @Select("select su.user_id,su.username,su.nickname,su.sex,su.photo " +
            "from sys_user su " +
            "where user_id not in (select user_id from ent_user where ent_id = #{ent_id}) " +
            "and nickname like #{nickname}")
    Page<SysUser> listUserNotInEnt(Page<SysUser> page, Integer ent_id, String nickname);


    @Select("SELECT " +
            "ee.*," +
            "eu.sort " +
            "FROM " +
            "`ent_enterprise` ee " +
            " left join ent_user eu on ee.ent_id = eu.ent_id " +
            "WHERE " +
            "eu.user_id = #{user_id} " +
            "ORDER BY eu.sort")
    Page<Enterprise> listMyEnt(Page<Enterprise> page, Integer user_id);


}
